﻿Public Class frmdangnhap

    Private Sub btndangnhap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndangnhap.Click

        Dim tendn As String = txttaikhoan.Text
        Dim matkhau As String = XL_NguoiDung.MD5(txtmatkhau.Text)

        If (tendn = "" Or matkhau = "") Then
            MessageBox.Show("Chưa nhập username hoặc password!", "Chú ý!")
        Else
            Dim mand As Integer = 0
            Dim kq As Integer = XL_NguoiDung.KiemTraDangNhap(tendn, matkhau, mand)
            If kq = 1 Then
                Dim f As New F2_Chuc_Nang
                f.Tag = mand
                f.Label2.Text = tendn
                f.Show()
                Me.Hide()

                Dim thucodinh As Integer = XL_ThuCoDinh.TuDongPhatSinh(mand)
                If thucodinh > 0 Then
                    MessageBox.Show("Đã cập nhật thêm " + thucodinh.ToString + " phiếu thu cố định)")
                End If
            ElseIf kq = 2 Then
                Dim f As New F2_Chuc_Nang
                f.Tag = mand
                f.Label2.Text = tendn
                f.Linkqlnd.Visible = True
                f.Show()
                Me.Hide()

                Dim thucodinh As Integer = XL_ThuCoDinh.TuDongPhatSinh(mand)
                If thucodinh > 0 Then
                    MessageBox.Show("Đã cập nhật thêm " + thucodinh.ToString + " nguồn thu cố định")
                End If

            Else
                MessageBox.Show("Username hoặc password không đúng!", "Chu y!")
            End If
        End If

    End Sub

    Private Sub btnthoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthoat.Click
        Me.Close()
    End Sub

    Private Sub lbldoimatkhau_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles lbldoimatkhau.LinkClicked
        Dim f As New F1_Doi_Mat_Khau
        f.ShowDialog()
    End Sub

    Private Sub txttaikhoan_TextChanged(sender As Object, e As EventArgs) Handles txttaikhoan.TextChanged

    End Sub
End Class
